import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/login'
import Layout from '@/views/layout'

// 引入首页的二级组件
import Home from '@/views/layout/home'
import Question from '@/views/layout/question'
import Video from '@/views/layout/video'
import User from '@/views/layout/user'

Vue.use(VueRouter)

const routes = [
  { name: 'Login', path: '/login', component: Login },
  {
    name: 'Layout',
    path: '/',
    component: Layout,
    children: [
      { name: 'Home', path: '/', component: Home },
      { name: 'Question', path: '/question', component: Question },
      { name: 'Video', path: '/video', component: Video },
      { name: 'User', path: '/user', component: User }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
